<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>采购订单sql生成器</title>
		<script src="jquery-1.11.2.min.js"></script>
	</head>
	<body>
		<textarea id="text" cols="100" rows="20"></textarea>
		<input type="button" value="生成" onclick="makeSql()"/>
		<script>
			function makeSql() {
				var lines = $("#text").val().split(/[\r\n]/);
				var sqlArray = [];
				
				for (var i = 0; i < lines.length; i++) {
					var line = lines[i];
					var nums = line.split(/[\s\n]/);
					
					//不含税单价	含税单价	不含税总金额	总税额	价税合计
//					op.product_price AS '不含税单价',
//					op.taxes_price AS '含税单价',
//					op.product_total_amount AS '不含税总金额',
//					op.taxes_amount AS '总税额',
//					op.total_amount AS '价税合计',
					//nopostage_total_amount 不包邮价税合计
					var sql = "UPDATE t_procuremanage_order_product SET "
					    	+ " product_price = " + nums[0] + ","
							+ " taxes_price = " + nums[1] + ","
							+ " product_total_amount = " + nums[2] + ","
							+ " taxes_amount = " + nums[3] + ","
							+ " total_amount = " + nums[4] + ","
							+ " nopostage_total_amount = " + nums[4]
							+ " WHERE id = " + nums[5] 
							+ " LIMIT 1;";
					sqlArray.push(sql);
				}
				alert(sqlArray.join("\r\n"));
				console.log(sqlArray.join("\r\n"))
			}
			
		</script>
	</body>
</html>
